home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Twirl.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  4.0 KB  |  161 lines

  1. /*
  2. ** $VER: Twirl.ieb 1.2, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 25/1 1997 Stockholm/Sweden
  6. **
  7. ** Twirl image, either one or multiple times.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xoff=128 ; Yoff=128 ; Radius=100 ; TwirlAmount=90
  42.  
  43.   if command ~= '' then parse var command Xoff Yoff Radius TwirlAmount '#'CalcType
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Twirl" " OK | Cancel "',
  48.   ' INTEGER,"Radius",0,4096,'Radius',SLIDER',
  49.   ' INTEGER,"Angle",-1800,1800,'TwirlAmount',SLIDER',
  50.   ' INTEGER,"X offset",0,4096,'Xoff',SLIDER',
  51.   ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER'
  52.  
  53.   if command = '' then do
  54.     form = form||' CYCLE,"Type:","Best|Fast",0'
  55.  
  56.     form
  57.     parse var result ok Radius TwirlAmount Xoff Yoff CalcType .
  58.     if ok = 0 then return '<ERROR>'
  59.  
  60.     if CalcType=0 then CalcType='BEST'
  61.     else CalcType = 'FAST'
  62.   end
  63.   else do
  64.     form
  65.     parse var result ok Radius TwirlAmount Xoff Yoff .
  66.     if ok = 0 then return '<ERROR>'
  67.  
  68.     CalcType = 'none'
  69.   end
  70.  
  71.   back = Xoff Yoff Radius TwirlAmount '#'CalcType
  72. return back
  73.  
  74. /* Required "Process_image" procedure  ------------------------------- */
  75.  
  76. process_image:
  77.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  78.   parse var options Xoff Yoff Radius TwirlAmount '#'CalcType
  79.  
  80.   'OPEN' '"'src_image'"' '24'
  81.   if (RC ~= 0) then do
  82.     'IE_TO_FRONT'
  83.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  84.     return '<ERROR>'
  85.   end
  86.   else LoadImage = result
  87.  
  88.   'PROJECT_INFO' LoadImage 'WIDTH'    /* Get width of image */
  89.   IW = RESULT
  90.   'PROJECT_INFO' LoadImage 'HEIGHT'    /* Get height of image */
  91.   IH = RESULT
  92.  
  93.   if Xoff >= (IW-1) then Xoff = (IW-1)
  94.   if Yoff >= (IH-1) then Yoff = (IH-1)
  95.   if Radius > max(IW,IH) then Radius = max(IW,IH)
  96.  
  97.   do while (TwirlAmount ~= 0)
  98.  
  99.     if TwirlAmount > 0 then do
  100.       if TwirlAmount > 359 then do
  101.         TA = 359
  102.         TwirlAmount = TwirlAmount - TA
  103.       end
  104.       else do
  105.         TA = TwirlAmount
  106.         TwirlAmount = TwirlAmount - TA
  107.       end
  108.     end
  109.     else do
  110.       if TwirlAmount < -359 then do
  111.         TA = -359
  112.         TwirlAmount = TwirlAmount - TA
  113.       end
  114.       else do
  115.         TA = TwirlAmount
  116.         TwirlAmount = TwirlAmount - TA
  117.       end
  118.     end
  119.  
  120.     'TWIRL' LoadImage Xoff Yoff Radius TA CalcType
  121.     NewImage = result
  122.     'CLOSE' LoadImage
  123.     LoadImage = NewImage
  124.  
  125.   end
  126.  
  127.   OutputImage = LoadImage
  128.  
  129.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  130.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  131.   if (RC ~= 0) then do
  132.     'IE_TO_FRONT'
  133.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  134.     return '<ERROR>'
  135.   end
  136.   'CLOSE' OutputImage
  137.  
  138.   back = 'OK'
  139. return back
  140.  
  141. /* Internal procedures  ---------------------------------------------- */
  142.  
  143. /*******************************************************************/
  144. /* This is where control goes when an error code is returned by IE */
  145. /* It puts up a message saying what happened and on which line     */
  146. /*******************************************************************/
  147.  
  148. error:
  149. if RC=5 then do
  150.     IE_TO_FRONT
  151.     LAST_ERROR
  152.     'REQUEST "'||RESULT||'"'
  153. end
  154. else do
  155.     IE_TO_FRONT
  156.     LAST_ERROR
  157.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  158. end
  159.  
  160. return '<ERROR>'
  161.